package ch.usi.inf.pf2;

import junit.framework.TestCase;

/**
 * @author Lorenzo Baracchi
 */
public class TestWriteSpreadSheetFile extends TestCase
{
    private WriteSpreadSheetFile spread;

    /**
     * Set up properly some standard variable for the tests.
     */
    protected void setUp()
    {
	   Sheet s = new Sheet();
	   s.initializeSheet();
	   s.insertDataAtCell("a", 1, 1); // A1
	   s.insertDataAtCell("2", 1, 2); // A2
	   s.insertDataAtCell("=A1+A2", 2, 1); // B1
	   spread = new WriteSpreadSheetFile(s, "test");
    }

    /**
     * Check that tryToOpen() method works as expected if someone tries to open
     * a file.
     */
    public void testTryToOpen()
    {
	   assertEquals(false, spread.tryToOpenFile());
    }

    /**
     * Check that
     */
    public void testFindLastOccurrence()
    {
	   assertEquals(2, spread.findLastOccurrence(1));
	   assertEquals(1, spread.findLastOccurrence(2));
    }

}